﻿using UnityEngine;
using System.Collections;
using MessageSystem;

public class MoveComponent : MonoBehaviour
{
    MessageTerminal messageTerminal;

    public Vector3 TargetPos { get; set; }

    public float Speed = 0.2f;

    public bool IsCanMove = true;
    // Use this for initialization
    void Start()
    {
        if (messageTerminal)
        {
            messageTerminal = GetComponent<MessageTerminal>();
            messageTerminal.RegisterMessage("MoveTo", OnMessage);
        }

    }

    // Update is called once per frame
    void Update()
    {

    }

    void OnMessage(IMessageArgs args)
    {
        MoveToArgs data = (MoveToArgs)args;
        if (data != null) 
        {
            TargetPos = data.TargetPos;
        }
    }
}